package main

import (
	"fmt"
	"os"
	"suanfa/pipeline"
)

func main() {
	const filename = "large.in"
	const n = 64

	file, err := os.Create(filename)
	if err != nil {
		panic(err)
	}
	defer file.Close()

	p := pipeline.RandomSource(n)
	pipeline.WriterSink(file, p)

	file, err = os.Open(filename)
	if err != nil {
		panic(err)
	}

	defer file.Close()

	p = pipeline.ReaderSource(file, -1)
	for v := range p {
		fmt.Println(v)
	}

}
func demo() {
	p := pipeline.Merge(pipeline.InMemSort(pipeline.ArraySource(3, 2, 6, 7, 4)),
		pipeline.InMemSort(pipeline.ArraySource(7, 4, 0, 3, 2, 5, 12, 1)))

	//for {
	//	num, ok := <-p
	//	if !ok {
	//		break
	//	}
	//	fmt.Println(num)
	//}

	for v := range p {
		fmt.Println(v)
	}

}
